package com.zkw.gra.dynamic

/**
 * Created by Administrator on 2016/4/11 0011.
 * 扩展属性的访问机制,可以动态创建获取没有的属性
 */
class ExtFieldAccMain {
    public count = 0
    Object get(String name){
        return 'pretend value'
    }
    void set(String name,Object value){
        count++
    }

    public static void main(String[] args) {
        def pretender = new ExtFieldAccMain()
        assert pretender.isNoField == 'pretend value'
        assert pretender.count == 0

        pretender.isNoFieldEither = 'just to increase count'
        assert pretender.count == 1
    }
}
